/*-------------------------------------------------------------------------------------------------------------------------------------------
Program: Rule_compliance_v5.do
----------------------------------------------------------------------------------------------------------------------------------------*/
*version Stata/SE 17.0

clear all
set more off
macro drop _all

cd "/Volumes/GoogleDrive/My Drive/Documents/JMP/Work/Tables/tables_replication_v2" 

use 				"merged_v0.31_replication.dta" , clear

gen inc = hh_inc/1000
*gen		rule_comp_percent	= 100*rule_compliance
gen 	dist_rule_norm 		= (rule-norm)/10 if rule!=0 & norm!=.
gen info40 = (norm40==1)
gen info60 = (norm60==1)
gen info40rule60 = (info40==1 & rule60==1)
gen info40rule100 = (info40==1 & rule100==1)
gen info60rule60 = (info60==1 & rule60==1)
gen info60rule100 = (info60==1 & rule100==1)

label var change_amt_sent "$\Delta$ Amount sent"
label var change_belief_sent "$\Delta$ Belief: Majority's Sending"
label var rule60 "Rule 60"
label var rule100 "Rule 100"
label var HC 	"High Caste"
label var inc "Income (rupees in '000's)"
label var  rule_compliance "Rule Compliance"
label var dist_rule_norm "Distance of rule from norm info (tens of rupees)"

label var info60rule60  "Info60Rule60 (dist = 0)"
label var info40rule60  "Info40Rule60 (dist = 20)"
label var info60rule100  "Info60Rule100 (dist = 40)"
label var info40rule100  "Info40Rule100 (dist = 60)"

encode session_id, gen(sess_id)
xtset sess_id
preserve
drop if female==. | work==. | age==. | educ==. | inc==. | christian==.
xtreg   rule_compliance  dist_rule_norm, re vce(cluster sess_id)
estadd local SessionFE "No"
est store 		a1


xtreg   rule_compliance  dist_rule_norm female work age educ inc christian, re vce(cluster sess_id)
estadd local SessionFE "No"
est store		a1_c


xtreg   rule_compliance  dist_rule_norm female work age educ inc christian i.sess_id, re vce(cluster sess_id)
estadd local SessionFE "Yes"
est store		a1_c_fe

xtreg   rule_compliance   info60rule60 info40rule60  info60rule100, re vce(cluster sess_id)
estadd local SessionFE "No"
est store 		a2

xtreg   rule_compliance  info60rule60 info40rule60  info60rule100 female work age educ inc christian, re vce(cluster sess_id)
estadd local SessionFE "No"
est store		a2_c

xtreg   rule_compliance  info60rule60 info40rule60  info60rule100 female work age educ inc christian i.sess_id, re vce(cluster sess_id)
estadd local SessionFE "Yes"
est store		a2_c_fe


esttab    a2 a2_c a2_c_fe a1 a1_c a1_c_fe  ///
		using "Table5_RuleCompliance_v2/rulecomp_dist_v3.tex" ,  ///
	  star(* 0.10 ** 0.05  *** 0.01) se(2) b(2) label ///
		title("Rule compliance of high-caste participants across information and rule treatments") replace 	///
		nonotes ///
		keep(info60rule60 info40rule60  info60rule100 dist_rule_norm female work age educ inc christian) scalars("SessionFE") ///
		tex addnotes("(1) GLS specification with session level random effects." ///
		             "(2) Standard errors in parentheses are clustered at the session level." ///
					 "(3) \sym{*} \(p<0.10\), \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)" ///
					 "(4) Info40Rule100 (dist = 60) is the reference category for Info60Rule60, Info40Rule60 and Info60Rule100." ///
					 "(5) Distance of rule from norm information is measured in tens of rupees." ///
					 "(6) High Caste is 1 if a participant is not SC/ST, is 0 otherwise." ///
					 "(7) Employed is 1 if a participant reports having a paid job, and is 0 otherwise." ///
					 "(8) Income is measured as the monthly household income." ///
					 "(9) The reference group for Christians is Hindus and Muslims.")

restore

exit
